home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / ProgrammeDisplay2.cs155 < prev    next >
Text File  |  2008-04-02  |  116KB  |  2,043 lines

  1. using System;
  2. using System.Collections;
  3. using System.IO;
  4. using System.Web;
  5. using System.Web.UI.WebControls;
  6. using GBPVR.Public;
  7.  
  8. namespace gbweb.classes
  9. {
  10.     /// <summary>
  11.     /// Summary description for ProgrammeDisplay.
  12.     /// </summary>
  13.     /// 
  14.     /// 
  15.     public class ProgrammeDisplay2 : IDisposable
  16.     {
  17.  
  18.         private string SortBy;
  19.         private string SecondarySortBy = "mrs_title";
  20.         private bool ExtendedEWAEnabled = false;
  21.         
  22.         public ProgrammeDisplay2()
  23.         {
  24.             if (getExtendedEWA())
  25.             {
  26.                 ExtendedEWA.OpenExtendedEWADB();
  27.             }
  28.         }
  29.  
  30.         #region IDisposable Members
  31.  
  32.         public void Dispose()
  33.         {
  34.             if (getExtendedEWA())
  35.             {
  36.                 //Close the ExtendedEWA DB
  37.                 ExtendedEWA.CloseExtendedEWADB();
  38.             }
  39.         }
  40.  
  41.         #endregion
  42.  
  43.         #region ExtendedEWA Detection
  44.  
  45.         private static bool ExtendedEWAToolCheck;
  46.         private static bool ExtendedEWALoaded = false;
  47.         private static bool getExtendedEWA()
  48.         {
  49.             if (!ExtendedEWALoaded)
  50.             {
  51.                 ExtendedEWAToolCheck = ExtendedEWA.Initialize();
  52.                 ExtendedEWALoaded = true;
  53.             }
  54.             return ExtendedEWAToolCheck;
  55.         }
  56.         #endregion
  57.  
  58.         public void FillProgrammeDisplay(HttpServerUtility Server, TableCell colShow, Programme programme, ScheduledRecording scheduledRecording, bool highlightRecordedShows)
  59.         {
  60.             //**************
  61.             //If you add functionality in this method you should review the FillProgrammeTreeArrayItem method as well
  62.             //**************
  63.             //
  64.             //This method fills a TableCell object with the formatted HTML code that is displayed
  65.  
  66.             Settings guideParams = Global.Settings;
  67.             string title = string.Empty;
  68.             string subtitle = string.Empty;
  69.             string href = null;
  70.             string onclick = string.Empty;
  71.             bool externallinks = true;
  72.             string description = string.Empty;
  73.             bool showAsRecording = false;
  74.  
  75.             if (scheduledRecording != null)
  76.             {
  77.                 switch (scheduledRecording.getRecordingType())
  78.                 {
  79.                     case ScheduledRecording.TYPE_RECORD_ONCE:
  80.                         if (programme == null) 
  81.                         {
  82.                             if (scheduledRecording.getFileName() != null && scheduledRecording.getFileName().Length > 0)
  83.                             {
  84.                                 title = "Manual Recording: " + scheduledRecording.getFileName();
  85.                             }
  86.                             else
  87.                             {
  88.                                 title = "Manual Recording";
  89.                             }
  90.                             externallinks = false;
  91.                         }
  92.                         break;
  93.                     default:
  94.                         title = scheduledRecording.getFileName();
  95.                         href = "Details2.aspx?rid=" + scheduledRecording.getOID();
  96.                         onclick = " onclick=\"EditPop5(this.href,'Add2');return false;\"";
  97.                         programme = null;
  98.                         break;
  99.                 }
  100.                 if (highlightRecordedShows) showAsRecording = true;
  101.             }
  102.  
  103.             ExtendedEWAEnabled = false;
  104.             const string new_show = "<div class=\"new_show\" title=\"New episode\">New</div>";
  105.             const string wiki1 = "<a href=\"";
  106.             const string wiki2 = " title=\"Wikipedia link\" class=\"wiki\">Wiki</a>";
  107.             const string netflix1 = "<a href=\"";
  108.             const string netflix2 = " title=\"Netflix link\" class=\"netflix\">Netflix</a>";
  109.             const string tvcom1 = "<a href=\"";
  110.             const string tvcom2 = " title=\"TV.com link\" class=\"tvcom\">TV.com</a>";
  111.             const string imdb1 = "<a href=\"";
  112.             const string imdb2 = " title=\"IMDB link\" class=\"imdb\">IMDB</a>";
  113.             const string infoClass1 = "\n<div class=\"info\">";
  114.             const string infoClass2 = "</div>\n";
  115.             string infoLinks = string.Empty;
  116.             string tooltip = string.Empty;
  117.  
  118.             if (programme != null)
  119.             {
  120.                 //Check to see if the ExtendedEWA DB is available
  121.                 ExtendedEWAEnabled = getExtendedEWA();
  122.  
  123.                 title = programme.getTitle().Replace("\"", "''");
  124.                 string extralinks = string.Empty;
  125.                 const string spacer = "<br><br>";
  126.  
  127.                 // Show the programme description for all EPG Users
  128.                 description = programme.getDescription().Replace("\"", "''");
  129.  
  130.                 if (description.Length > 0)
  131.                 {
  132.                     tooltip = description;
  133.                 }
  134.  
  135.                 subtitle = programme.getSubTitle().Replace("\"", "''");
  136.                 if (subtitle.Length > 0)
  137.                 {
  138.                     // If there's no description, then add the subtitle as the description
  139.                     if (description.Length == 0 && !guideParams.showSubtitle)
  140.                     {
  141.                         tooltip = subtitle;
  142.                         description = subtitle;
  143.                     }
  144.                 }
  145.                 
  146.                 if (!guideParams.showDescription)
  147.                 {
  148.                     description = string.Empty;
  149.                 }
  150.                 // If you are not displaying the description but there is a subtitle then set the variable title to SubTitle
  151.                 else if (guideParams.showSubtitle)
  152.                 {
  153.                     subtitle = programme.getSubTitle().Replace("\"", "''");
  154.                 }
  155.  
  156.                 // Add a double line break if there are other things to display below the description
  157.                 if ((guideParams.showGenre != "noGenre") || (guideParams.showRating) || (ExtendedEWAEnabled && (guideParams.showNew || guideParams.showCredits)))
  158.                 {
  159.                     description += spacer + " ";
  160.                 }
  161.  
  162.                 // Retrieve the rating for the show
  163.                 if (guideParams.showRating)
  164.                 {
  165.                     string rating = programme.getRating();
  166.                     //Since this is the first item being added to the variable extalinks we don't need to add line breaks since it was taken care of by
  167.                     if (rating != null && rating.Length > 0)
  168.                     {
  169.                         extralinks += "Rated: " + programme.getRating();
  170.                     }
  171.                 }
  172.  
  173.                 // Add the show Genre to the line
  174.                 if (guideParams.showGenre != "noGenre")
  175.                 {
  176.                     ArrayList genreCheck = programme.getGenreList();
  177.                     for (int unknownPos = genreCheck.BinarySearch("unknown", new CaseInsensitiveComparer()); unknownPos > -1;
  178.                              unknownPos = genreCheck.BinarySearch("unknown", new CaseInsensitiveComparer()))
  179.                     {
  180.                         genreCheck.RemoveAt(unknownPos);
  181.                     }
  182.                     for (int unknownPos = genreCheck.BinarySearch(string.Empty, new CaseInsensitiveComparer()); unknownPos > -1;
  183.                         unknownPos = genreCheck.BinarySearch(string.Empty, new CaseInsensitiveComparer()))
  184.                     {
  185.                         genreCheck.RemoveAt(unknownPos);
  186.                     }
  187.                     if (genreCheck.Count > 0)
  188.                     {
  189.                         //If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  190.                         if (extralinks.Length > 0) extralinks += "<br>";
  191.                         if (guideParams.showGenre == "allGenre")
  192.                         {
  193.                             extralinks += "Genre" + (genreCheck.Count > 1 ? "s" : string.Empty) + ": " + string.Join(", ", (string[])genreCheck.ToArray(typeof(string)));
  194.                         }
  195.                         else
  196.                         {
  197.                             extralinks += "Genre: " + genreCheck[0];
  198.                         }
  199.                     }
  200.                 }
  201.  
  202.                 // If the user has ExtendedEWA append additional information to the description when found
  203.                 if (ExtendedEWAEnabled)
  204.                 {
  205.                     string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
  206.                     // Pull the Airdate of the Show or the Release Year of the movie and the Start Rating for Movie
  207.                     string[] programInfo = ExtendedEWA.GetProgramInfo(programUniqueIdentifier);
  208.  
  209.                     if (guideParams.showAirDate || guideParams.showStarRating)
  210.                     {
  211.                         if (programInfo.Length > 0)
  212.                         {
  213.                             if (programUniqueIdentifier.StartsWith("MV"))
  214.                             {
  215.                                 if ((guideParams.showAirDate) && (programInfo[0] != "0"))
  216.                                 {
  217.                                     // If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  218.                                     if (extralinks.Length > 0) extralinks += "<br>";
  219.                                     extralinks += " Movie Release Year: " + programInfo[0].ToString();
  220.                                 }
  221.                                 if ((guideParams.showStarRating) && (programInfo[2] != "none"))
  222.                                 {
  223.                                     // If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  224.                                     if (extralinks.Length > 0) extralinks += "<br>";
  225.                                     extralinks += " Star Rating: " + programInfo[2];
  226.                                 }
  227.                             }
  228.                             else
  229.                             {
  230.                                 if ((guideParams.showAirDate) && (programInfo[1] != "none"))
  231.                                 {
  232.                                     // If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  233.                                     if (extralinks.Length > 0) extralinks += "<br>";
  234.                                     extralinks += " Original Air Date: " + programInfo[1];
  235.                                 }
  236.                             }
  237.                         }
  238.                     }
  239.  
  240.                     // Check the ExtendedEWA supplemental database to see if the show is a new show
  241.                     if (guideParams.showNew)
  242.                     {
  243.                         if (ExtendedEWA.IsNew(programUniqueIdentifier))
  244.                         {
  245.                             // If show is new tag an indicator at the end of the description indicating so
  246.                             // If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  247.                             infoLinks += new_show;
  248.                         }
  249.                             //We need to check to see if the airdate is >= to today since the New show identifier is not reliable.
  250.                             //If the airdate is >= programme air date then we can assume it is a new show
  251.                         else if (programInfo.Length > 0)
  252.                         {
  253.                             if (!programUniqueIdentifier.StartsWith("MV"))
  254.                             {
  255.                                 if (programInfo[1] != "none")
  256.                                 {
  257.                                     try
  258.                                     {
  259.                                         DateTime airDate = Convert.ToDateTime(programInfo[1]);
  260.                                         if (airDate.Date >= programme.getStartTime().Date)
  261.                                         {
  262.                                             infoLinks += new_show;
  263.                                         }
  264.                                     }
  265.                                     catch (Exception e)
  266.                                     {
  267.                                     }
  268.                                 }
  269.                             }
  270.                         }
  271.                     }
  272.  
  273.                     // Check the ExtendedEWA supplemental database to see if the show is a new show
  274.                     if (guideParams.showHD)
  275.                     {
  276.                         if (ExtendedEWA.IsHD(programUniqueIdentifier))
  277.                         {
  278.                             // If show is a High Def (HD) tag an indicator at the end of the description indicating the show is in HD
  279.                             // If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  280.  
  281.                             if (extralinks.Length > 0) extralinks += "<br>";
  282.                             extralinks += "<b> HD </b>";
  283.                         }
  284.                     }
  285.  
  286.                     // Provide a link to see Cast information
  287.                     if (guideParams.showCredits)
  288.                     {
  289.                         // If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  290.                         if (extralinks.Length > 0) extralinks += "<br>";
  291.                         extralinks += "(<a href=\"Credits2.aspx?id=" + programme.getOID() + "\" onclick=\"EditPop2(this.href,'Add1');return false;\">Credits</a>)";
  292.                     }
  293.                 }
  294.  
  295.                 href = "Details2.aspx?id=" + programme.getOID();
  296.                 if (scheduledRecording != null)
  297.                 {
  298.                     if (highlightRecordedShows) showAsRecording = true;
  299.                     href += "&rid=" + scheduledRecording.getOID();
  300.                 }
  301.                 onclick = " onclick=\"EditPop5(this.href,'Add2');return false;\"";
  302.  
  303.                 if (extralinks != string.Empty)
  304.                 {
  305.                     description = description + extralinks;
  306.                 }
  307.                 
  308.             }
  309.             else
  310.             {
  311.                 if (scheduledRecording.getRecordingType() != ScheduledRecording.TYPE_RECORD_SEASON)
  312.                 {
  313.                     if (scheduledRecording.getFileName() != null && scheduledRecording.getFileName().Length > 0)
  314.                     {
  315.                         title = "Manual Recording: " + scheduledRecording.getFileName();
  316.                     }
  317.                     else
  318.                     {
  319.                         title = "Manual Recording";
  320.                     }
  321.                     externallinks = false;
  322.                 }
  323.             }
  324.  
  325.             // Add external links (these must be added in reverse order)
  326.             // Show the show link to Wikipedia for all EPG Users
  327.             if (externallinks && guideParams.showWiki)
  328.             {
  329.                 infoLinks += wiki1 + "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=" + Server.UrlEncode(title) + "\" target=\"_blank\"" + wiki2;
  330.                 //description = " (<a href=\"http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=" + Server.UrlEncode(title) + "\" target=\"_blank\">Wiki</a>)" + description;
  331.             }
  332.             // Show the show link to TV.Com for all EPG Users
  333.             if (externallinks && guideParams.showTVCom)
  334.             {
  335.                 infoLinks += tvcom1 + "http://www.google.com/search?hl=en&q=site%3Awww.tv.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"" + tvcom2;
  336.                 //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.tv.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">TV.Com</a>)" + description;
  337.             }
  338.             // Show the show link to Netflix for all EPG Users
  339.             if (externallinks && guideParams.showNetflix)
  340.             {
  341.                 string tmpNet = string.Empty;
  342.                 if (programme != null)
  343.                 {
  344.                     string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
  345.  
  346.                     if (programUniqueIdentifier.StartsWith("MV"))
  347.                     {
  348.                         if (ExtendedEWAEnabled)
  349.                         {
  350.                             ArrayList cast = ExtendedEWA.GetCast(programUniqueIdentifier);
  351.                             if (cast.Count > 0)
  352.                             {
  353.                                 ExtendedEWA.Crew crew = (ExtendedEWA.Crew) cast[0];
  354.                                 tmpNet = "http://www.google.com/search?hl=en&q=site%3Awww.netflix.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
  355.                                 //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.netflix.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">NetFlix</a>)" + description;
  356.                             }
  357.                             else
  358.                             {
  359.                                 tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  360.                                 //description = " (<a href=\"http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\">Netflix</a>)" + description;
  361.                             }
  362.                         }
  363.                         else
  364.                         {
  365.                             tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  366.                             //description = " (<a href=\"http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\">Netflix</a>)" + description;  
  367.                         }
  368.                     }
  369.                     else
  370.                     {
  371.                         tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  372.                         //description = " (<a href=\"http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\">Netflix</a>)" + description;  
  373.                     }
  374.                 }
  375.                 else
  376.                 {
  377.                     tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  378.                     //description = " (<a href=\"http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\">Netflix</a>)" + description;  
  379.                 }
  380.                 infoLinks += netflix1+ tmpNet + netflix2;
  381.             }
  382.  
  383.             // Show the show link to IMDB for all EPG Users
  384.             if (externallinks && guideParams.showIMDB)
  385.             {
  386.                 string tmpIMDB = string.Empty;
  387.                 if (programme != null)
  388.                 {
  389.                     if (subtitle != null && subtitle != "")
  390.                     {
  391.                         tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
  392.                         //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">IMDB</a>)" + description;
  393.                     }
  394.                     else
  395.                     {
  396.                         if (ExtendedEWAEnabled)
  397.                         {
  398.                             string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
  399.                             ArrayList cast = ExtendedEWA.GetCast(programUniqueIdentifier);
  400.                             if (cast.Count > 0)
  401.                             {
  402.                                 ExtendedEWA.Crew crew = (ExtendedEWA.Crew) cast[0];
  403.                                 if (programUniqueIdentifier.StartsWith("MV"))
  404.                                 {
  405.                                     tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "+%22Directed+by%22+-%22date+of+birth%22&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
  406.                                     //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "+%22Directed+by%22+-%22date+of+birth%22&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">IMDB</a>)" + description;
  407.                                 }
  408.                                 else
  409.                                 {
  410.                                     tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+%22TV-Series%22+&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
  411.                                     //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+%22TV-Series%22+&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">IMDB</a>)" + description;
  412.                                 }
  413.                             }
  414.                             else
  415.                             {
  416.                                 tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  417.                                 //description = " (<a href=\"http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\">IMDB</a>)" + description;
  418.                             }
  419.                         }
  420.                         else
  421.                         {
  422.                             tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  423.                             //description = " (<a href=\"http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\">IMDB</a>)" + description;
  424.                         }
  425.                     }
  426.                 }
  427.                 else
  428.                 {
  429.                     tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  430.                     //description = " (<a href=\"http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\">IMDB</a>)" + description;
  431.                 }
  432.                 infoLinks += imdb1 + tmpIMDB + imdb2;
  433.             }
  434.  
  435.             if (showAsRecording)
  436.             {
  437.                 int showStatus = scheduledRecording.getRecordingStatus();
  438.                 switch (showStatus)
  439.                 {
  440.                     case ScheduledRecording.STATUS_PENDING:
  441.                         colShow.CssClass = "listingPending";
  442.                         break;
  443.                     case ScheduledRecording.STATUS_IN_PROGRESS:
  444.                         colShow.CssClass = "listingInProgress";
  445.                         break;
  446.                     case ScheduledRecording.STATUS_COMPLETED:
  447.                         colShow.CssClass = "listingAvailable";
  448.                         break;
  449.                     case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
  450.                         colShow.CssClass = "listingFailed";
  451.                         break;
  452.                     case ScheduledRecording.STATUS_CONFLICT:
  453.                         colShow.CssClass = "listingConflict";
  454.                         break;
  455.                     default:
  456.                         colShow.CssClass = "listingAvailable";
  457.                         break;
  458.                 }
  459.             }
  460.             else
  461.             {
  462.                 colShow.CssClass = "listing";
  463.             }
  464.             
  465.             if (href != null)
  466.             {
  467.                 if (subtitle.Length > 0)
  468.                 {
  469.                     title = "<div class=\"showTitle\" title=\"" + tooltip + "\" >" + "<a href=\"" + href + "\"" + onclick + ">" + title + "<div class=\"showSubtitle\" title=\"" + tooltip + "\">" + subtitle + "</div>" + "</a></div>\n";
  470.                 }
  471.                 else
  472.                 {
  473.                     title = "<div class=\"showTitle\" title=\"" + tooltip + "\" >" + "<a href=\"" + href + "\"" + onclick + ">" + title + "</a></div>\n";
  474.                 }
  475.                 
  476.             }
  477.             else
  478.             {
  479.                 if (subtitle.Length > 0)
  480.                 {
  481.                     title = "<div class=\"showTitle\" title=\"" + tooltip + "\" >" + title + "</div>" + "<div class=\"showSubtitle\" title=\"" + tooltip + "\">" + subtitle + "</div>\n"; 
  482.                 }
  483.                 else
  484.                 {
  485.                     title = "<div class=\"showTitle\" title=\"" + tooltip + "\" >" + title + "</div>\n";  
  486.                 }
  487.                 
  488.             }
  489.             if (description.Length > 0) title += "<div class=\"showText\">" + description + "</div>\n";
  490.             if (infoLinks.Length > 0)
  491.             {
  492.                 title = infoClass1 + infoLinks + infoClass2 + title;
  493.             }
  494.             colShow.Text = title;
  495.         }
  496.  
  497.         public void FillProgrammeTreeArrayItem(ProgramTreeItem treeItem, HttpServerUtility Server, Programme programme, ScheduledRecording scheduledRecording, bool highlightRecordedShows, Channel channel)
  498.         {
  499.             //**************
  500.             //If you add functionality in this method you should review the FillProgramme method as well
  501.             //**************
  502.             //
  503.             //This method fills a ProgrammeTreeItem object with the formatted HTML code that is displayed
  504.  
  505.             Settings guideParams = Global.Settings;
  506.             string title = string.Empty;
  507.             string subtitle = string.Empty;
  508.             string title2 = string.Empty;
  509.             string subtitle2 = string.Empty;
  510.             string href = string.Empty;
  511.             string onclick = string.Empty;
  512.             string description = string.Empty;
  513.             bool showAsRecording = false;
  514.             bool ManualRecording = false;
  515.             bool externallinks = false;
  516.  
  517.             if (scheduledRecording != null)
  518.             {
  519.                 if (highlightRecordedShows) showAsRecording = true;
  520.             }
  521.  
  522.             ExtendedEWAEnabled = false;
  523.             const string new_show = "<div class=\"new_show\" title=\"New episode\">New</div>";
  524.             const string wiki1 = "<a href=\"";
  525.             const string wiki2 = " title=\"Wikipedia link\" class=\"wiki\">Wiki</a>";
  526.             const string netflix1 = "<a href=\"";
  527.             const string netflix2 = " title=\"Netflix link\" class=\"netflix\">Netflix</a>";
  528.             const string tvcom1 = "<a href=\"";
  529.             const string tvcom2 = " title=\"TV.com link\" class=\"tvcom\">TV.com</a>";
  530.             const string imdb1 = "<a href=\"";
  531.             const string imdb2 = " title=\"IMDB link\" class=\"imdb\">IMDB</a>";
  532.             const string infoClass1 = "\n<div class=\"info\">";
  533.             const string infoClass2 = "</div>\n";
  534.             string infoLinks = string.Empty;
  535.             string tooltip = string.Empty;
  536.             
  537.             if (programme != null)
  538.             {
  539.                 externallinks = true;
  540.                 //Check to see if the ExtendedEWA DB is available
  541.                 ExtendedEWAEnabled = getExtendedEWA();
  542.  
  543.                 //Set the onclick event variable
  544.                 onclick = " onclick=\"EditPop5(this.href,'Add2');return false;\"";
  545.  
  546.                 //Set the Title and Subtitle variables
  547.                 title = programme.getTitle().Replace("\"", "''");
  548.                 subtitle = programme.getSubTitle().Replace("\"", "''");
  549.  
  550.                 title2 = programme.getTitle().Replace("\"", "''");
  551.                 subtitle2 = programme.getSubTitle().Replace("\"", "''");
  552.  
  553.                 tooltip = string.Empty;
  554.                 description = programme.getDescription().Replace("\"", "''");
  555.                 if (description.Length > 0)
  556.                 {
  557.                     tooltip = description;
  558.                     treeItem.setDescription("<span class=\"showText\">" + description + "</span>\n");
  559.                 }
  560.  
  561.                 if (subtitle.Length > 0)
  562.                 {
  563.                     // If there's no description, then add the subtitle as the description
  564.                     if (description.Length == 0 && !guideParams.showSubtitle)
  565.                     {
  566.                         tooltip = subtitle;
  567.                         description = subtitle;
  568.                         treeItem.setDescription("<span class=\"showText\">" + description + "</span>\n");
  569.                     }
  570.                 }
  571.  
  572.                 treeItem.setTitle("<div class=\"showTitle\" title=\"" + tooltip + "\" >" + title + "</div>\n");
  573.                 treeItem.setRawTitle(programme.getTitle().Replace("\"", "''"));
  574.  
  575.                 string subtitleFmt;
  576.                 if (subtitle.Length > 0)
  577.                 {
  578.                     subtitleFmt = "<span class=\"listing\">Subtitle: </span>";
  579.                     subtitleFmt += "<span class=\"showSubtitle\" title=\"" + tooltip + "\">" + subtitle + "</span>\n";
  580.                 }
  581.                 else
  582.                 {
  583.                     subtitleFmt = "<span class=\"listing\">Subtitle: </span>";
  584.                     subtitleFmt += "<span class=\"showSubtitle\" title=\"None Available\">None Available</span>\n";
  585.                 }
  586.                 
  587.                 treeItem.setSubTitle(subtitleFmt);
  588.  
  589.                 // Retrieve the rating for the show
  590.                 if (guideParams.showRating)
  591.                 {
  592.                     string rating = programme.getRating();
  593.                     //Since this is the first item being added to the variable extalinks we don't need to add line breaks since it was taken care of by
  594.                     if (rating != null && rating.Length > 0)
  595.                     {
  596.                         treeItem.setRating("<span class=\"listing\">" + "Rated: " + programme.getRating() + "</span>");
  597.                     }
  598.                 }
  599.                
  600.                 // Add the show Genre
  601.                 if (guideParams.showGenre != "noGenre")
  602.                 {
  603.                     ArrayList genreCheck = programme.getGenreList();
  604.                     for (int unknownPos = genreCheck.BinarySearch("unknown", new CaseInsensitiveComparer()); unknownPos > -1;
  605.                              unknownPos = genreCheck.BinarySearch("unknown", new CaseInsensitiveComparer()))
  606.                     {
  607.                         genreCheck.RemoveAt(unknownPos);
  608.                     }
  609.                     for (int unknownPos = genreCheck.BinarySearch(string.Empty, new CaseInsensitiveComparer()); unknownPos > -1;
  610.                         unknownPos = genreCheck.BinarySearch(string.Empty, new CaseInsensitiveComparer()))
  611.                     {
  612.                         genreCheck.RemoveAt(unknownPos);
  613.                     }
  614.                     if (genreCheck.Count > 0)
  615.                     {
  616.                         //If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  617.                         if (guideParams.showGenre == "allGenre")
  618.                         {
  619.                             treeItem.setGenre("<span class=\"listing\">" + "Genre" + (genreCheck.Count > 1 ? "s" : string.Empty) + ": " + string.Join(", ", (string[])genreCheck.ToArray(typeof(string))) + "</span>");
  620.                         }
  621.                         else
  622.                         {
  623.                             treeItem.setGenre("<span class=\"listing\">" + "Genre: " + genreCheck[0] + "</span>");
  624.                         }
  625.                     }
  626.                     else
  627.                     {
  628.                         treeItem.setGenre("<span class=\"listing\">" + "No Genre Found:" + "</span>");
  629.                     }
  630.                 }
  631.                 
  632.                 // If the user has ExtendedEWA append additional information to the description when found
  633.                 if (ExtendedEWAEnabled)
  634.                 {
  635.                     string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
  636.                     // Pull the Airdate of the Show or the Release Year of the movie and the Start Rating for Movie
  637.                     string[] programInfo = ExtendedEWA.GetProgramInfo(programUniqueIdentifier);
  638.                     
  639.                     if (guideParams.showAirDate || guideParams.showStarRating)
  640.                     {
  641.                         if (programInfo.Length > 0)
  642.                         {
  643.                             if (programUniqueIdentifier.StartsWith("MV"))
  644.                             {
  645.                                 if ((guideParams.showAirDate) && (programInfo[0] != "0"))
  646.                                 {
  647.                                     treeItem.setReleaseYear("<span class=\"listing\">" + "Movie Release Year: " + programInfo[0].ToString() + "</span>");
  648.                                 }
  649.                                 if ((guideParams.showStarRating) && (programInfo[2] != "none"))
  650.                                 {
  651.                                     treeItem.setStarRating("<span class=\"listing\">" + "Star Rating: " + programInfo[2] + "</span>");
  652.                                 }
  653.                             }
  654.                             else
  655.                             {
  656.                                 if ((guideParams.showAirDate) && (programInfo[1] != "none"))
  657.                                 {
  658.                                     treeItem.setOriginalAirDate("<span class=\"listing\">" + "Original Air Date: " + programInfo[1] + "</span>");
  659.                                     treeItem.setRawOriginalAirDate(programInfo[1]);
  660.                                 }
  661.                             }
  662.                         }
  663.                     }
  664.                     
  665.                     // Check the ExtendedEWA supplemental database to see if the show is a new show
  666.                     if (guideParams.showNew)
  667.                     {
  668.                         if (ExtendedEWA.IsNew(programUniqueIdentifier))
  669.                         {
  670.                             treeItem.setNew_Show("<span class=\"new_show\" title=\"New episode\">New</span>");
  671.                         }
  672.                             //We need to check to see if the airdate is >= to today since the New show identifier is not reliable.
  673.                             //If the airdate is >= programme air date then we can assume it is a new show
  674.                         else if (programInfo.Length > 0)
  675.                         {
  676.                             if (!programUniqueIdentifier.StartsWith("MV"))
  677.                             {
  678.                                 if (programInfo[1] != "none")
  679.                                 {
  680.                                     try
  681.                                     {
  682.                                         DateTime airDate = Convert.ToDateTime(programInfo[1]);
  683.                                         if (airDate.Date >= programme.getStartTime().Date)
  684.                                         {
  685.                                             treeItem.setNew_Show("<span class=\"new_show\" title=\"New episode\">New</span>");
  686.                                         }
  687.                                     }
  688.                                     catch (Exception e)
  689.                                     {
  690.                                     }
  691.                                 }
  692.                             }
  693.                         }
  694.                     }
  695.  
  696.                     if (guideParams.showHD)
  697.                     {
  698.                         if (ExtendedEWA.IsHD(programUniqueIdentifier))
  699.                         {
  700.                             // If show is a High Def (HD) tag an indicator at the end of the description indicating the show is in HD
  701.                             // If another extralink was previously added we want to single space this one down otherwise no extra line is needed
  702.                             treeItem.setHD("<span class=\"subtitle\">" + "<b> HD </b>" + "</span>");
  703.                         }
  704.                     }
  705.  
  706.                     // Provide a link to see Cast information
  707.                     if (guideParams.showCredits)
  708.                     {
  709.                         treeItem.setCredits("<span class=\"listing\">" + "<a href=\"Credits2.aspx?id=" + programme.getOID() + "\" onclick=\"EditPop2(this.href,'Add1');return false;\">Credits</a>" + "</span>");
  710.                     }
  711.                 }
  712.                 
  713.                 if (showAsRecording)
  714.                 {
  715.                     int showStatus = scheduledRecording.getRecordingStatus();
  716.                     switch (showStatus)
  717.                     {
  718.                         case ScheduledRecording.STATUS_PENDING:
  719.                             treeItem.setRecordingDisplayClass("treelistingPending");
  720.                             treeItem.setStatus("Pending");
  721.                             break;
  722.                         case ScheduledRecording.STATUS_IN_PROGRESS:
  723.                             treeItem.setRecordingDisplayClass("treelistingInProgress");
  724.                             treeItem.setStatus("In-Progress");
  725.                             break;
  726.                         case ScheduledRecording.STATUS_COMPLETED:
  727.                             treeItem.setRecordingDisplayClass("treelistingAvailable");
  728.                             treeItem.setStatus("Available");
  729.                             break;
  730.                         case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
  731.                             treeItem.setRecordingDisplayClass("treelistingFailed");
  732.                             treeItem.setStatus("Failed");
  733.                             break;
  734.                         case ScheduledRecording.STATUS_CONFLICT:
  735.                             treeItem.setRecordingDisplayClass("treelistingConflict");
  736.                             treeItem.setStatus("Conflict");
  737.                             break;
  738.                         case ScheduledRecording.STATUS_PLACE_HOLDER:
  739.                             treeItem.setRecordingDisplayClass("treelistingReocurring");
  740.                             treeItem.setStatus("Reocurring");
  741.                             break;    
  742.                         default:
  743.                             treeItem.setRecordingDisplayClass("listing");
  744.                             treeItem.setStatus("Unknown");
  745.                             break;
  746.                     }
  747.                 }
  748.                 else
  749.                 {
  750.                     treeItem.setRecordingDisplayClass("listing");
  751.                 }
  752.  
  753.                 treeItem.setAirDate("<span class=\"listing\">" + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString() + "</span>");
  754.                 treeItem.setrawAirDateStartTime(programme.getStartTime());
  755.                 treeItem.setrawAirDateEndTime(programme.getEndTime());
  756.  
  757.                 if (channel != null)
  758.                 {
  759.                     treeItem.setChannelDisplay("<span class=\"listing\">" + channel.getName() + "</span>");
  760.                     treeItem.setChannelName(channel.getName());
  761.                     treeItem.setChannel(channel.getChannelNumber());
  762.                 }
  763.                 else
  764.                 {
  765.                     treeItem.setChannelDisplay("<span class=\"listing\">No Channel Info Found 1</span>");
  766.                     treeItem.setChannelName("No Channel Info Found 1");
  767.                 }
  768.  
  769.                 href = "Details2.aspx?id=" + programme.getOID();
  770.                 if (scheduledRecording != null)
  771.                 {
  772.                     href += "&rid=" + scheduledRecording.getOID();
  773.                 }
  774.             }
  775.             else
  776.             {
  777.                 ManualRecording = true;
  778.                 string subtitleFmt = string.Empty;
  779.                 if (scheduledRecording.getRecordingType() != ScheduledRecording.TYPE_RECORD_SEASON)
  780.                 {
  781.                     treeItem.setGenre("<span class=\"listing\">" + "Genre: Manual Recording" + "</span>");
  782.                     if (scheduledRecording.getFileName() != null && scheduledRecording.getFileName().Length > 0)
  783.                     {
  784.                         title = "Manual Recording: ";
  785.                         subtitleFmt = "<span class=\"listing\">" + "Subtitle: " + "</span>";
  786.                         subtitleFmt += "<span class=\"subtitle\">" + scheduledRecording.getFileName() + "</span>";
  787.                     }
  788.                     else
  789.                     {
  790.                         title = "Manual Recording";
  791.                         subtitleFmt = "<span class=\"listing\">" + "Subtitle: " + "</span>";
  792.                         subtitleFmt += "<span class=\"subtitle\">" + "None Available" + "</span>";
  793.                     }
  794.                 }
  795.                 else
  796.                 {
  797.                     title = scheduledRecording.getFileName();
  798.                     href = "Details2.aspx?rid=" + scheduledRecording.getOID();
  799.                     title = "<a href=\"" + href + "\"" + "\" onclick=\"EditPop5(this.href,'Add1');return false;\">" + title + "</a>";
  800.  
  801.                     treeItem.setTitle("<span class=\"listing\"> " + title + "</span>");
  802.                     treeItem.setGenre("<span class=\"listing\">" + "Genre: Season Recording" + "</span>");
  803.                     if (scheduledRecording.getStartTime().Year != 0001)
  804.                     {
  805.                         subtitleFmt = "<span class=\"listing\">" + scheduledRecording.getStartTime().ToShortTimeString() + " - " + scheduledRecording.getEndTime().ToShortTimeString() + "</span>";
  806.                     }
  807.                     externallinks = false;
  808.                 }
  809.                 treeItem.setTitle("<span class=\"listing\"> " + title + "</span>");
  810.                 treeItem.setRawTitle(title);
  811.                 treeItem.setSubTitle(subtitleFmt);
  812.                 if (showAsRecording)
  813.                 {
  814.                     int showStatus = scheduledRecording.getRecordingStatus();
  815.                     switch (showStatus)
  816.                     {
  817.                         case ScheduledRecording.STATUS_PENDING:
  818.                             treeItem.setRecordingDisplayClass("treelistingPending");
  819.                             treeItem.setStatus("Pending");
  820.                             break;
  821.                         case ScheduledRecording.STATUS_IN_PROGRESS:
  822.                             treeItem.setRecordingDisplayClass("treelistingInProgress");
  823.                             treeItem.setStatus("In-Progress");
  824.                             break;
  825.                         case ScheduledRecording.STATUS_COMPLETED:
  826.                             treeItem.setRecordingDisplayClass("treelistingAvailable");
  827.                             treeItem.setStatus("Available");
  828.                             break;
  829.                         case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
  830.                             treeItem.setRecordingDisplayClass("treelistingFailed");
  831.                             treeItem.setStatus("Failed");
  832.                             break;
  833.                         case ScheduledRecording.STATUS_CONFLICT:
  834.                             treeItem.setRecordingDisplayClass("treelistingConflict");
  835.                             treeItem.setStatus("Conflict");
  836.                             break;
  837.                         case ScheduledRecording.STATUS_PLACE_HOLDER:
  838.                             treeItem.setRecordingDisplayClass("treelistingReocurring");
  839.                             treeItem.setStatus("Reocurring");
  840.                             break;
  841.                         default:
  842.                             treeItem.setRecordingDisplayClass("listing");
  843.                             treeItem.setStatus("Unknown");
  844.                             break;
  845.                     }
  846.                 }
  847.                 else
  848.                 {
  849.                     treeItem.setRecordingDisplayClass("listing");
  850.                 }
  851.  
  852.                 if (channel != null)
  853.                 {
  854.                     treeItem.setChannelDisplay("<span class=\"channelName\">" + channel.getName() + "</span>");
  855.                     treeItem.setChannelName(channel.getName());
  856.                     treeItem.setChannel(channel.getChannelNumber());
  857.                 }
  858.                 else
  859.                 {
  860.                     treeItem.setChannelDisplay("<span class=\"channelName\">No Channel Info Found 2</span>");
  861.                     treeItem.setChannelName("No Channel Info Found 2");
  862.                 }
  863.             }
  864.  
  865.             // Add external links (these must be added in reverse order)
  866.             // Show the show link to Wikipedia for all EPG Users
  867.             if (guideParams.showWiki && externallinks)
  868.             {
  869.                 infoLinks += wiki1 + "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=" + Server.UrlEncode(title) + "\" target=\"_blank\"" + wiki2;
  870.             }
  871.             // Show the show link to TV.Com for all EPG Users
  872.             if (guideParams.showTVCom && externallinks)
  873.             {
  874.                 infoLinks += tvcom1 + "http://www.google.com/search?hl=en&q=site%3Awww.tv.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"" + tvcom2;
  875.             }
  876.             // Show the show link to Netflix for all EPG Users
  877.             if (guideParams.showNetflix && externallinks)
  878.             {
  879.                 string tmpNet = string.Empty;
  880.                 string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
  881.  
  882.                 if (programUniqueIdentifier.StartsWith("MV"))
  883.                 {
  884.                     if (ExtendedEWAEnabled)
  885.                     {
  886.                         ArrayList cast = ExtendedEWA.GetCast(programUniqueIdentifier);
  887.                         if (cast.Count > 0)
  888.                         {
  889.                             ExtendedEWA.Crew crew = (ExtendedEWA.Crew)cast[0];
  890.                             tmpNet = "http://www.google.com/search?hl=en&q=site%3Awww.netflix.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
  891.                             //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.netflix.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">NetFlix</a>)" + description;
  892.                         }
  893.                         else
  894.                         {
  895.                             tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  896.                             //description = " (<a href=\"http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\">Netflix</a>)" + description;
  897.                         }
  898.                     }
  899.                     else
  900.                     {
  901.                         tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  902.                         //description = " (<a href=\"http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\">Netflix</a>)" + description;  
  903.                     }
  904.                 }
  905.                 else
  906.                 {
  907.                     tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  908.                     //description = " (<a href=\"http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\">Netflix</a>)" + description;  
  909.                 }
  910.                 
  911.                 infoLinks += netflix1 + tmpNet + netflix2;
  912.             }
  913.             // Show the show link to IMDB for all EPG Users
  914.             if (guideParams.showIMDB && externallinks)
  915.             {
  916.                 string tmpIMDB = string.Empty;
  917.                 if (subtitle != null && subtitle != "")
  918.                 {
  919.                     tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
  920.                     //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">IMDB</a>)" + description;
  921.                 }
  922.                 else
  923.                 {
  924.                     if (ExtendedEWAEnabled)
  925.                     {
  926.                         string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
  927.                         ArrayList cast = ExtendedEWA.GetCast(programUniqueIdentifier);
  928.                         if (cast.Count > 0)
  929.                         {
  930.                             ExtendedEWA.Crew crew = (ExtendedEWA.Crew)cast[0];
  931.                             if (programUniqueIdentifier.StartsWith("MV"))
  932.                             {
  933.                                 tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "+%22Directed+by%22+-%22date+of+birth%22&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
  934.                                 //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "+%22Directed+by%22+-%22date+of+birth%22&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">IMDB</a>)" + description;
  935.                             }
  936.                             else
  937.                             {
  938.                                 tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+%22TV-Series%22+&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
  939.                                 //description = " (<a href=\"http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+%22TV-Series%22+&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\">IMDB</a>)" + description;
  940.                             }
  941.                         }
  942.                         else
  943.                         {
  944.                             tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  945.                             //description = " (<a href=\"http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\">IMDB</a>)" + description;
  946.                         }
  947.                     }
  948.                     else
  949.                     {
  950.                         tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
  951.                         //description = " (<a href=\"http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\">IMDB</a>)" + description;
  952.                     }
  953.                 }
  954.                 infoLinks += imdb1 + tmpIMDB + imdb2;
  955.             }
  956.  
  957.             treeItem.setTitle("<b>" + treeItem.title + "</b>");
  958.             
  959.             if (!ManualRecording)
  960.             {
  961.                 treeItem.setChannelDisplay("<a href=\"" + href + "\"" + onclick + ">" + treeItem.channelDisplay + "</a>");
  962.             }
  963.  
  964.             try
  965.             {
  966.                 treeItem.setProgrammeOID(programme.getOID().ToString()); 
  967.             }
  968.             catch(Exception ex)
  969.             {
  970.                 
  971.             }
  972.  
  973.             string options = "";
  974.             bool strmAllowed = File.Exists(Path.Combine(guideParams.strmVLCLoc, "vlc.exe"));
  975.             try
  976.             {
  977.                 switch (scheduledRecording.getRecordingStatus())
  978.                 {
  979.                     case ScheduledRecording.STATUS_PENDING:
  980.                         options = "<br><br><span class=\"butCancel\"><a href=\"Manage2.aspx?cancel=" + scheduledRecording.getOID() + "\">Cancel Recording</span></a><br>";
  981.                         treeItem.setButtonOptions(options);
  982.                         break;
  983.                     case ScheduledRecording.STATUS_IN_PROGRESS:
  984.                         options = "<br><br><span class=\"butPlay\"><a href=\"" + Download.GetDownloadUrl(false, false, scheduledRecording.getOID()) + "\">Play Program</span></a>" +
  985.                                   "<span class=\"butDownload\"><a href=\"" + Download.GetDownloadUrl(true, true, scheduledRecording.getOID()) + "\">Download</span></a>";
  986.                         if (strmAllowed)
  987.                         {
  988.                             options += "<span class=\"butStream\"><a href=\"public/Player2.aspx?rid=" + scheduledRecording.getOID() + "&type=mr" + "\" onclick=\"EditPop5(this.href,'Add1');return false;\">Stream</span></a>";
  989.                         }
  990.                         if (programme == null)
  991.                         {
  992.                             options += "<span class=\"butCancel\"><a href=\"Manage2.aspx?cancel=" + scheduledRecording.getOID() + "\">Cancel Recording</span></a>";
  993.                         }
  994.                         options += "<br>";
  995.                         treeItem.setButtonOptions(options);
  996.                         break;
  997.                     case ScheduledRecording.STATUS_COMPLETED:
  998.                         options = "<br><br><span class=\"butPlay\"><a href=\"" + Download.GetDownloadUrl(false, false, scheduledRecording.getOID()) + "\">Play Program</span></a>" +
  999.                                   "<span class=\"butDownload\"><a href=\"" + Download.GetDownloadUrl(true, true, scheduledRecording.getOID()) + "\">Download</span></a>";
  1000.                         if (strmAllowed)
  1001.                         {
  1002.                             options += "<span  class=\"butStream\"><a href=\"public/Player2.aspx?rid=" + scheduledRecording.getOID() + "&type=mr" + "\" onclick=\"EditPop5(this.href,'Add1');return false;\">Stream</span></a>";
  1003.                         }
  1004.                         if (programme == null)
  1005.                         {
  1006.                             options += "<span class=\"butDelete\"><a href=\"Manage2.aspx?cancel=" + scheduledRecording.getOID() + "\">Delete</span></a>";
  1007.                         }
  1008.                         options += "<br>";
  1009.                         treeItem.setButtonOptions(options);
  1010.                         break;
  1011.                     case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
  1012.                         options = "<br><br><span class=\"butDelete\"><a href=\"Manage2.aspx?cancel=" + scheduledRecording.getOID() + "\">Delete</span></a><br>";
  1013.                         treeItem.setButtonOptions(options);
  1014.                         break;
  1015.                     case ScheduledRecording.STATUS_CONFLICT:
  1016.                         options = "<br><br><span  class=\"butDelete\"><a href=\"Manage2.aspx?cancel=" + scheduledRecording.getOID() + "\"><Delete</span></a><br>";
  1017.                         treeItem.setButtonOptions(options);
  1018.                         break;
  1019.                     case ScheduledRecording.STATUS_PLACE_HOLDER:
  1020.                         options = "<br><br><span class=\"butCancel\"><a href=\"Manage2.aspx?cancel=" + scheduledRecording.getOID() + "\">Cancel Recording</span></a><br>";
  1021.                         treeItem.setButtonOptions(options);
  1022.                         break;
  1023.                     case ScheduledRecording.STATUS_DELETED:
  1024.                         options = "<br><br><span class=\"title\">" + "Deleted" + "</span><br>";
  1025.                         treeItem.setButtonOptions(options);
  1026.                         break;
  1027.                     default:
  1028.                         treeItem.setButtonOptions("NONE!!");
  1029.                         break;
  1030.                 }
  1031.             }
  1032.             catch(Exception ex)
  1033.             {
  1034.                 
  1035.             }
  1036.             
  1037.         }
  1038.  
  1039.         public void FillProgrammeTree(TreeView treeView, ProgramTreeItem[] treeItemArray, string sortBy, string secondarySortBy)
  1040.         {
  1041.             SecondarySortBy = secondarySortBy;
  1042.             FillProgrammeTree(treeView, treeItemArray, sortBy);
  1043.         }
  1044.         
  1045.         public void FillProgrammeTree(TreeView treeView, ProgramTreeItem [] treeItemArray, string sortBy)
  1046.         {
  1047.  
  1048.             SortBy = sortBy;
  1049.             //**************
  1050.             //This method Sorts and then loops through an Array of ProgrammeTreeItems to load them into
  1051.             //a Treview control that is passed in.
  1052.             //**************
  1053.             //
  1054.  
  1055.             //Pull in the global settings
  1056.             Settings guideParams = Global.Settings;
  1057.  
  1058.             //Create a new sort object for the arrary of TreeItems
  1059.             ProgramTreeItem_Sort sortArray;
  1060.  
  1061.             //Initialize the sort object with the correct sort parameter that defines what order the items will
  1062.             //be sorted in
  1063.             switch (SecondarySortBy)
  1064.             {
  1065.                 case "mrs_title":
  1066.                     {
  1067.                         switch (sortBy)
  1068.                         {
  1069.                             case "title":
  1070.                                 {
  1071.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1072.                                     break;
  1073.                                 }
  1074.                             case "genre":
  1075.                                 {
  1076.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1077.                                     break;
  1078.                                 }
  1079.                             case "rating":
  1080.                                 {
  1081.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1082.                                     break;
  1083.                                 }
  1084.                             case "star":
  1085.                                 {
  1086.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1087.                                     break;
  1088.                                 }
  1089.                             case "date":
  1090.                                 {
  1091.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1092.                                     break;
  1093.                                 }
  1094.                             case "originalAirDate":
  1095.                                 {
  1096.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByOriginalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1097.                                     break;
  1098.                                 }
  1099.                             case "mr_title":
  1100.                                 {
  1101.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1102.                                     break;
  1103.                                 }
  1104.                             case "mr_genre":
  1105.                                 {
  1106.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1107.                                     break;
  1108.                                 }
  1109.                             case "mr_rating":
  1110.                                 {
  1111.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1112.                                     break;
  1113.                                 }
  1114.                             case "mr_star":
  1115.                                 {
  1116.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1117.                                     break;
  1118.                                 }
  1119.                             case "mr_date":
  1120.                                 {
  1121.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1122.                                     break;
  1123.                                 }
  1124.                             case "mr_channel":
  1125.                                 {
  1126.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByChannel, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1127.                                     break;
  1128.                                 }
  1129.                             case "mr_status":
  1130.                                 {
  1131.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStatus, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1132.                                     break;
  1133.                                 }
  1134.                             case "mr_original_date":
  1135.                                 {
  1136.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByOrignalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1137.                                     break;
  1138.                                 }
  1139.                             default:
  1140.                                 {
  1141.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
  1142.                                     break;
  1143.                                 }
  1144.                         }
  1145.                         break;
  1146.                     }
  1147.                 case "mrs_date":
  1148.                     {
  1149.                         switch (sortBy)
  1150.                         {
  1151.                             case "title":
  1152.                                 {
  1153.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1154.                                     break;
  1155.                                 }
  1156.                             case "genre":
  1157.                                 {
  1158.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1159.                                     break;
  1160.                                 }
  1161.                             case "rating":
  1162.                                 {
  1163.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1164.                                     break;
  1165.                                 }
  1166.                             case "star":
  1167.                                 {
  1168.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1169.                                     break;
  1170.                                 }
  1171.                             case "date":
  1172.                                 {
  1173.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1174.                                     break;
  1175.                                 }
  1176.                             case "mr_title":
  1177.                                 {
  1178.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1179.                                     break;
  1180.                                 }
  1181.                             case "mr_genre":
  1182.                                 {
  1183.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1184.                                     break;
  1185.                                 }
  1186.                             case "mr_rating":
  1187.                                 {
  1188.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1189.                                     break;
  1190.                                 }
  1191.                             case "mr_star":
  1192.                                 {
  1193.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1194.                                     break;
  1195.                                 }
  1196.                             case "mr_date":
  1197.                                 {
  1198.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1199.                                     break;
  1200.                                 }
  1201.                             case "mr_channel":
  1202.                                 {
  1203.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByChannel, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1204.                                     break;
  1205.                                 }
  1206.                             case "mr_status":
  1207.                                 {
  1208.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStatus, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1209.                                     break;
  1210.                                 }
  1211.                             case "mr_original_date":
  1212.                                 {
  1213.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByOrignalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1214.                                     break;
  1215.                                 }
  1216.                             default:
  1217.                                 {
  1218.                                     sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1219.                                     break;
  1220.                                 }
  1221.                         }
  1222.                         break;
  1223.                     }
  1224.                 default:
  1225.                     {
  1226.                         sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
  1227.                         break;
  1228.                     }
  1229.             }
  1230.  
  1231.             //Sort the array of TreeItems using the custom sort object
  1232.             Array.Sort(treeItemArray, sortArray);             
  1233.  
  1234.             //Initialize looping variables to 0
  1235.             int idx1 = 0;
  1236.             int idx2 = 0;
  1237.  
  1238.             //Initialize all the display nodes for the tree
  1239.             TreeNode alternateRoot = new TreeNode();
  1240.             TreeNode root = new TreeNode();
  1241.             TreeNode child1 = new TreeNode();
  1242.             TreeNode child2 = new TreeNode();
  1243.             TreeNode child3 = new TreeNode();
  1244.             TreeNode child4 = new TreeNode();
  1245.             TreeNode child5 = new TreeNode();
  1246.             TreeNode child6 = new TreeNode();
  1247.             TreeNode child7 = new TreeNode();
  1248.             TreeNode child8 = new TreeNode();
  1249.             TreeNode child9 = new TreeNode();
  1250.             TreeNode child10 = new TreeNode();
  1251.             TreeNode child11 = new TreeNode();
  1252.             TreeNode child12 = new TreeNode();
  1253.  
  1254.             //Loop through all the TreeItems in the array....building the TreeView
  1255.             while (idx1 < treeItemArray.Length)
  1256.             {
  1257.                 //Set idx2 to the previous index number....this is used to compare the current item to the
  1258.                 //previous item that was loaded into the tree....this tells us where to break to build a new node
  1259.                 idx2 = idx1 - 1;
  1260.                 //Set variable treeItem1 to the first array object
  1261.                 ProgramTreeItem treeItem1 = treeItemArray[idx1];
  1262.                 //Initialize the variable treeItem2
  1263.                 ProgramTreeItem treeItem2 = new ProgramTreeItem();
  1264.                 //We only want to set the variable treeItem2 to the previous item in the array if we have already
  1265.                 //loaded the first item in the array....so if the previous index number (idx2) is 0 or greater we
  1266.                 //have processed the first item in the array already
  1267.                 if (idx2 > -1)
  1268.                 {
  1269.                     treeItem2 = treeItemArray[idx2];
  1270.                 }
  1271.                 //If we are on the first item in the array then we need to load the info into the TreeView and move
  1272.                 //on to processing the next array item
  1273.                 if (idx1 == 0)
  1274.                 {
  1275.                     //If the sort is on anything but title we have to build the main grouper node
  1276.                     if (sortBy != "title" && sortBy != "mr_title")
  1277.                     {
  1278.                         if (sortBy == "status" || sortBy == "mr_status")
  1279.                         {
  1280.                             //Set the grouper node to not do anything when the text of the node is clicked on
  1281.                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1282.                             //Set the node text to the current Status.
  1283.                             alternateRoot.Text = treeItem1.status;
  1284.                         }
  1285.                         else if (sortBy == "channel" || sortBy == "mr_channel")
  1286.                         {
  1287.                             //Set the grouper node to not do anything when the text of the node is clicked on
  1288.                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1289.                             //Set the node text to the current Channel
  1290.                             alternateRoot.Text = treeItem1.channelName;
  1291.                         }
  1292.                         else if (sortBy == "originalAirDate" || sortBy == "mr_original_date")
  1293.                         {
  1294.                             //Set the grouper node to not do anything when the text of the node is clicked on
  1295.                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1296.                             //Set the node text to the original air date
  1297.                             if (guideParams.showAirDate)
  1298.                             {
  1299.                                 if (treeItem1.rawOriginalAirDate != null)
  1300.                                 {
  1301.                                     alternateRoot.Text = treeItem1.originalAirDate;
  1302.                                 }
  1303.                                 else
  1304.                                 {
  1305.                                     alternateRoot.Text = "No Original Air Date Found:";
  1306.                                 }
  1307.                             }
  1308.                             else
  1309.                             {
  1310.                                 alternateRoot.Text = "Original Air Date not selected to display in Configuration Tab:";
  1311.                             }
  1312.                         }
  1313.                         else if (sortBy == "genre" || sortBy == "mr_genre")
  1314.                             {
  1315.                                 //Set the grouper node to not do anything when the text of the node is clicked on
  1316.                                 alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1317.                                 //Check to see if the user has selected to show Genre or not....if not then give them
  1318.                                 //a message indicating this.....otherwise set the node text to the current Genre.
  1319.                                 if (guideParams.showGenre != "noGenre")
  1320.                                 {
  1321.                                     alternateRoot.Text = treeItem1.genre;
  1322.                                 }
  1323.                                 else
  1324.                                 {
  1325.                                     alternateRoot.Text = "Genre not selected to display in Configuration Tab:";
  1326.                                 }
  1327.                             }    
  1328.                         else if (sortBy == "rating" || sortBy == "mr_rating")
  1329.                             {
  1330.                                 //Set the grouper node to not do anything when the text of the node is clicked on
  1331.                                 alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1332.                                 //Check to see if the user has selected to show Rating or not....if not then give them
  1333.                                 //a message indicating this.....otherwise set the node text to the current Rating.
  1334.  
  1335.                                 if (guideParams.showRating)
  1336.                                 {
  1337.                                     if (treeItem1.rating != null)
  1338.                                     {
  1339.                                         alternateRoot.Text = treeItem1.rating;
  1340.                                     }
  1341.                                     else
  1342.                                     {
  1343.                                         alternateRoot.Text = "No Rating Found:";
  1344.                                     }
  1345.                                 }
  1346.                                 else
  1347.                                 {
  1348.                                     alternateRoot.Text = "Rating not selected to display in Configuration Tab:";
  1349.                                 }
  1350.                             }
  1351.                         else if (sortBy == "star"  || sortBy == "mr_star")
  1352.                             {
  1353.                                 //Set the grouper node to not do anything when the text of the node is clicked on
  1354.                                 alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1355.                                 //Check to see if the user has selected to show Star Rating or not....if not then give them
  1356.                                 //a message indicating this.....otherwise set the node text to the current Star Rating.
  1357.  
  1358.                                 if (guideParams.showStarRating)
  1359.                                 {
  1360.                                     if (treeItem1.starRating != null)
  1361.                                     {
  1362.                                         alternateRoot.Text = treeItem1.starRating;
  1363.                                     }
  1364.                                     else
  1365.                                     {
  1366.                                         alternateRoot.Text = "No Star Rating Found:";
  1367.                                     }
  1368.                                 }
  1369.                                 else
  1370.                                 {
  1371.                                     alternateRoot.Text = " Star Rating not selected to display in Configuration Tab:";
  1372.                                 }
  1373.                             }
  1374.                         else if (sortBy == "date")
  1375.                             {
  1376.                                 //Set the grouper node to not do anything when the text of the node is clicked onalternateRoot.SelectAction = TreeNodeSelectAction.None;
  1377.                                 if (treeItem1.rawAirDateStartTime != null)
  1378.                                 {
  1379.                                     alternateRoot.Text = treeItem1.airDate;
  1380.                                 }
  1381.                                 else
  1382.                                 {
  1383.                                     alternateRoot.Text = "No Air Date Found:";
  1384.                                 }
  1385.                             }
  1386.                         else if (sortBy == "mr_date")
  1387.                             {
  1388.                                 //Set the grouper node to not do anything when the text of the node is clicked onalternateRoot.SelectAction = TreeNodeSelectAction.None;
  1389.                                 if (treeItem1.rawAirDateStartTime != null)
  1390.                                 {
  1391.                                     alternateRoot.Text = treeItem1.rawAirDateStartTime.ToLongDateString();
  1392.                                 }
  1393.                                 else
  1394.                                 {
  1395.                                     alternateRoot.Text = "No Air Date Found:";
  1396.                                 }
  1397.                             } 
  1398.                     }
  1399.                     //Fill a complete TreeView Item including the top level of the item
  1400.                     root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
  1401.                                                 child6, child7, child8, child9, child10, child11, child12, true);
  1402.                 }
  1403.                 else
  1404.                 {
  1405.                     //This code is executed for the second item in the array through the end of the array
  1406.                     //
  1407.                     //If you are either not sorting by the date or if you are sorting by the date and both the current
  1408.                     //item and the previous item have the same air date then we do not need to break for a new node
  1409.                     if ((sortBy == "date" && treeItem1.rawAirDateStartTime == treeItem2.rawAirDateStartTime) ||
  1410.                         (sortBy == "mr_date" && treeItem1.rawAirDateStartTime.ToLongDateString() == treeItem2.rawAirDateStartTime.ToLongDateString()) ||
  1411.                         (sortBy == "mr_originalDate" && treeItem1.rawOriginalAirDate == treeItem2.rawOriginalAirDate) ||
  1412.                         (sortBy == "originalAirDate" && treeItem1.rawOriginalAirDate == treeItem2.rawOriginalAirDate) ||
  1413.                         (sortBy == "mr_channel" && treeItem1.channel == treeItem2.channel) ||
  1414.                         (sortBy == "mr_status" && treeItem1.status == treeItem2.status) ||
  1415.                         (sortBy != "mr_original_Date" && sortBy != "originalAirDate" && sortBy != "date" && sortBy != "mr_date" && sortBy != "mr_channel" && sortBy != "mr_status"))
  1416.                     {
  1417.                         //If the titles of the current and previous item match there is no need to break for a new node
  1418.                         if (treeItem1.rawTitle == treeItem2.rawTitle)
  1419.                         {
  1420.                             //If the subtitles of the current and previous item match there is no need to break for a
  1421.                             //new node
  1422.                             if (treeItem1.subtitle == treeItem2.subtitle)
  1423.                             {
  1424.                                 if (treeItem1.description == treeItem2.description)
  1425.                                 {
  1426.                                     //If this item has a status such as recorded, failed, etc then we need to replace the text so that 
  1427.                                     //it displays with the correct highlighting which is stored in the RecordingDisplayClaiss of the treeItem. 
  1428.                                     if (treeItem1.getRecordingDisplayClass() != "listing")
  1429.                                     {
  1430.                                         child1.Text =
  1431.                                             child1.Text.Replace("class=\"listing\"",
  1432.                                                                 "class=\"" + treeItem1.displayClass + "\"");
  1433.                                         child1.Text =
  1434.                                             child1.Text.Replace("class=\"showSubtitle\"",
  1435.                                                                 "class=\"" + treeItem1.displayClass + "\"");
  1436.                                     }
  1437.                                     //if the current and previous items are not on the same date we want to have a node
  1438.                                     //break so that we have a node for each date the show is airing on
  1439.                                     if (treeItem1.rawAirDateStartTime != treeItem2.rawAirDateStartTime)
  1440.                                     {
  1441.                                         //Initialize the two treenodes that are needed
  1442.                                         child11 = new TreeNode();
  1443.                                         child12 = new TreeNode();
  1444.                                         //Set the airdate to display
  1445.                                         FillProgrammeTreeAirDate(treeItem1, child11);
  1446.                                         //Set this node to do nothing when the text is clicked on
  1447.                                         child11.SelectAction = TreeNodeSelectAction.None;
  1448.                                         //We want this node to be expanded automatically
  1449.                                         child11.Expand();
  1450.                                         //If this item has a status such as recorded, failed, etc then we need to replace the text so that 
  1451.                                         //it displays with the correct highlighting which is stored in the RecordingDisplayClaiss of the treeItem. 
  1452.                                         if (treeItem1.displayClass != "listing")
  1453.                                         {
  1454.                                             child11.Text =
  1455.                                                 child11.Text.Replace("class=\"listing\"",
  1456.                                                                      "class=\"" + treeItem1.displayClass + "\"");
  1457.                                         }
  1458.                                         //Add the node to the tree
  1459.                                         child1.ChildNodes.Add(child11);
  1460.  
  1461.                                         //Set the channel info in the node
  1462.                                         FillProgrammeTreeChannel(treeItem1, child12);
  1463.                                         //Set the text in the node to do nothing when clicked on
  1464.                                         child12.SelectAction = TreeNodeSelectAction.None;
  1465.                                         //If the treeitem does not have any recording status then we want to let the user
  1466.                                         //select to record the show by using a checkbox
  1467.                                         if (treeItem1.displayClass == "listing")
  1468.                                         {
  1469.                                             child12.ShowCheckBox = true;
  1470.                                         }
  1471.                                         //Add the node to the tree
  1472.                                         child11.ChildNodes.Add(child12);
  1473.                                     }
  1474.                                     else
  1475.                                     {
  1476.                                         //Since the airdates for the current and previous items matched we only need to create
  1477.                                         //a node for the channel that the show is displaying on
  1478.                                         //
  1479.                                         //Initialize the treenode is needed
  1480.                                         child12 = new TreeNode();
  1481.                                         //Set the channel info in the node
  1482.                                         FillProgrammeTreeChannel(treeItem1, child12);
  1483.                                         //Set the text in the node to do nothing when clicked on
  1484.                                         //If the treeitem does not have any recording status then we want to let the user
  1485.                                         //select to record the show by using a checkbox
  1486.                                         child12.SelectAction = TreeNodeSelectAction.None;
  1487.                                         if (treeItem1.displayClass == "listing")
  1488.                                         {
  1489.                                             child12.ShowCheckBox = true;
  1490.                                         }
  1491.                                         child11.ChildNodes.Add(child12);
  1492.                                     }
  1493.                                 }
  1494.                                 else
  1495.                                 {
  1496.                                     //Since the descriptions are different between the current item and the previous item we
  1497.                                     //need to create a new node for all the show info.  However, since the Titles match
  1498.                                     //we do not create a new main root node.
  1499.                                     child1 = new TreeNode();
  1500.                                     child2 = new TreeNode();
  1501.                                     child3 = new TreeNode();
  1502.                                     child4 = new TreeNode();
  1503.                                     child5 = new TreeNode();
  1504.                                     child6 = new TreeNode();
  1505.                                     child7 = new TreeNode();
  1506.                                     child8 = new TreeNode();
  1507.                                     child9 = new TreeNode();
  1508.                                     child10 = new TreeNode();
  1509.                                     child11 = new TreeNode();
  1510.                                     child12 = new TreeNode();
  1511.                                     root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
  1512.                                     child6, child7, child8, child9, child10, child11, child12, false);
  1513.                                     
  1514.                                 }
  1515.                             }
  1516.                             else
  1517.                             {
  1518.                                 //Since the subtitles are different between the current item and the previous item we
  1519.                                 //need to create a new node for all the show info.  However, since the Titles match
  1520.                                 //we do not create a new main root node.
  1521.                                 child1 = new TreeNode();
  1522.                                 child2 = new TreeNode();
  1523.                                 child3 = new TreeNode();
  1524.                                 child4 = new TreeNode();
  1525.                                 child5 = new TreeNode();
  1526.                                 child6 = new TreeNode();
  1527.                                 child7 = new TreeNode();
  1528.                                 child8 = new TreeNode();
  1529.                                 child9 = new TreeNode();
  1530.                                 child10 = new TreeNode();
  1531.                                 child11 = new TreeNode();
  1532.                                 child12 = new TreeNode();
  1533.                                 root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
  1534.                                 child6, child7, child8, child9, child10, child11, child12, false);
  1535.                             }
  1536.                         }
  1537.                         else
  1538.                         {
  1539.                             //Since the Titles of the current and previous item do not match we need to create a
  1540.                             //new node to hold all the show info
  1541.                             //
  1542.                             //If we are not sorting by title then we are grouping by some other characteristic.
  1543.                             if (sortBy != "title" && sortBy != "mr_title")
  1544.                             {
  1545.                                 //Add the new node to the grouping node (alternateRoot)
  1546.                                 alternateRoot.ChildNodes.Add(root);
  1547.                                 //If the grouping item is different between the current item and the previous item then
  1548.                                 //we need to create a new grouping node
  1549.                                 if (sortBy == "mr_status")
  1550.                                     {
  1551.                                         if (treeItem1.status != treeItem2.status)
  1552.                                         {
  1553.                                             //Set the grouper node to not do anything when the text of the node is clicked on
  1554.                                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1555.                                             //Set the node text to the current Status.
  1556.                                             alternateRoot.Text = treeItem1.status;
  1557.                                         }
  1558.                                     }
  1559.                                 else if (sortBy == "mr_channel")
  1560.                                     {
  1561.                                         if (treeItem1.channel != treeItem2.channel)
  1562.                                         {
  1563.                                             //Set the grouper node to not do anything when the text of the node is clicked on
  1564.                                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1565.                                             //Set the node text to the current Channel
  1566.                                             alternateRoot.Text = treeItem1.channelName;
  1567.                                         }
  1568.                                     }
  1569.                                 else if (sortBy == "genre" || sortBy == "mr_genre")
  1570.                                     {
  1571.                                         if (treeItem1.genre != treeItem2.genre)
  1572.                                         {
  1573.                                             //Add the grouping node to the treeview
  1574.                                             treeView.Nodes.Add(alternateRoot);
  1575.                                             //Initialize a new grouping node
  1576.                                             alternateRoot = new TreeNode();
  1577.                                             //set the grouping node to do nothing when the text of the node is selected
  1578.                                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1579.                                             //Check to see if the user has selected to show Genre or not....if not then give them
  1580.                                             //a message indicating this.....otherwise set the node text to the current Genre.
  1581.                                             if (guideParams.showGenre != "noGenre")
  1582.                                             {
  1583.                                                 alternateRoot.Text = treeItem1.genre;
  1584.                                             }
  1585.                                             else
  1586.                                             {
  1587.                                                 alternateRoot.Text = "Genre not selected to display in Configuration Tab:";
  1588.                                             }
  1589.                                         }
  1590.                                     }
  1591.                                 else if (sortBy == "rating" || sortBy == "mr_rating")
  1592.                                     {
  1593.                                         if (treeItem1.rating != treeItem2.rating)
  1594.                                         {
  1595.                                             //Add the grouping node to the treeview
  1596.                                             treeView.Nodes.Add(alternateRoot);
  1597.                                             //Initialize a new grouping node
  1598.                                             alternateRoot = new TreeNode();
  1599.                                             //set the grouping node to do nothing when the text of the node is selected
  1600.                                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1601.                                             //Check to see if the user has selected to show Rating or not....if not then give them
  1602.                                             //a message indicating this.....otherwise set the node text to the current Rating.
  1603.  
  1604.                                             if (guideParams.showRating)
  1605.                                             {
  1606.                                                 if (treeItem1.rating != null)
  1607.                                                 {
  1608.                                                     alternateRoot.Text = treeItem1.rating;
  1609.                                                 }
  1610.                                                 else
  1611.                                                 {
  1612.                                                     alternateRoot.Text = "No Rating Found:";
  1613.                                                 }
  1614.                                             }
  1615.                                             else
  1616.                                             {
  1617.                                                 alternateRoot.Text = "Rating not selected to display in Configuration Tab:";
  1618.                                             }
  1619.                                         }
  1620.                                     }
  1621.                                 else if (sortBy == "star" || sortBy == "mr_star")
  1622.                                     {
  1623.                                         if (treeItem1.starRating != treeItem2.starRating)
  1624.                                         {
  1625.                                             //Add the grouping node to the treeview
  1626.                                             treeView.Nodes.Add(alternateRoot);
  1627.                                             //Initialize a new grouping node
  1628.                                             alternateRoot = new TreeNode();
  1629.                                             //set the grouping node to do nothing when the text of the node is selected
  1630.                                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1631.                                             //Check to see if the user has selected to show Star Rating or not....if not then give them
  1632.                                             //a message indicating this.....otherwise set the node text to the current Star Rating.
  1633.                                             if (guideParams.showStarRating)
  1634.                                             {
  1635.                                                 if (treeItem1.starRating != null)
  1636.                                                 {
  1637.                                                     alternateRoot.Text = treeItem1.starRating;
  1638.                                                 }
  1639.                                                 else
  1640.                                                 {
  1641.                                                     alternateRoot.Text = "No Star Rating Found:";
  1642.                                                 }
  1643.                                             }
  1644.                                             else
  1645.                                             {
  1646.                                                 alternateRoot.Text = "Star Rating not selected to display in Configuration Tab:";
  1647.                                             }
  1648.                                         }
  1649.                                     }
  1650.                                else if (sortBy == "originalAirDate" || sortBy == "mr_original_date")
  1651.                                     {
  1652.                                         if (treeItem1.rawOriginalAirDate != treeItem2.rawOriginalAirDate)
  1653.                                         {
  1654.                                             //Add the grouping node to the treeview
  1655.                                             treeView.Nodes.Add(alternateRoot);
  1656.                                             //Initialize a new grouping node
  1657.                                             alternateRoot = new TreeNode();
  1658.                                             //set the grouping node to do nothing when the text of the node is selected
  1659.                                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1660.                                             //Check to see if the user has selected to show Star Rating or not....if not then give them
  1661.                                             //a message indicating this.....otherwise set the node text to the current Star Rating.
  1662.                                             if (guideParams.showAirDate)
  1663.                                             {
  1664.                                                 if (treeItem1.rawOriginalAirDate != null)
  1665.                                                 {
  1666.                                                     alternateRoot.Text = treeItem1.originalAirDate;
  1667.                                                 }
  1668.                                                 else
  1669.                                                 {
  1670.                                                     alternateRoot.Text = "No Orignal Air Date Found:";
  1671.                                                 }
  1672.                                             }
  1673.                                             else
  1674.                                             {
  1675.                                                 alternateRoot.Text = "Orignal Air Date not selected to display in Configuration Tab:";
  1676.                                             }
  1677.                                         }
  1678.                                     }
  1679.                                 else if (sortBy == "date")
  1680.                                     {
  1681.                                         if (treeItem1.rawAirDateStartTime != treeItem2.rawAirDateStartTime ||
  1682.                                            (treeItem1.rawAirDateStartTime == treeItem2.rawAirDateStartTime && treeItem1.rawAirDateEndTime != treeItem2.rawAirDateEndTime))
  1683.                                         {
  1684.                                             //Add the grouping node to the treeview
  1685.                                             treeView.Nodes.Add(alternateRoot);
  1686.                                             //Initialize a new grouping node
  1687.                                             alternateRoot = new TreeNode();
  1688.                                             //set the grouping node to do nothing when the text of the node is selected
  1689.                                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1690.                                             if (treeItem1.rawAirDateStartTime != null)
  1691.                                             {
  1692.                                                 alternateRoot.Text = treeItem1.airDate;
  1693.                                             }
  1694.                                             else
  1695.                                             {
  1696.                                                 alternateRoot.Text = "No Air Date Found:";
  1697.                                             }
  1698.                                         }
  1699.                                     }
  1700.                                 else if (sortBy == "mr_date")
  1701.                                     {
  1702.                                         if (treeItem1.rawAirDateStartTime.ToLongDateString() != treeItem2.rawAirDateStartTime.ToLongDateString())
  1703.                                         {
  1704.                                             //Add the grouping node to the treeview
  1705.                                             treeView.Nodes.Add(alternateRoot);
  1706.                                             //Initialize a new grouping node
  1707.                                             alternateRoot = new TreeNode();
  1708.                                             //set the grouping node to do nothing when the text of the node is selected
  1709.                                             alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1710.                                             if (treeItem1.rawAirDateStartTime != null)
  1711.                                             {
  1712.                                                 alternateRoot.Text = treeItem1.rawAirDateStartTime.ToLongDateString();
  1713.                                             }
  1714.                                             else
  1715.                                             {
  1716.                                                 alternateRoot.Text = "No Air Date Found:";
  1717.                                             }
  1718.                                         }
  1719.                                     } 
  1720.                             }
  1721.                             else
  1722.                             {
  1723.                                 //Since we are sorting by title we just add the node to the TreeView
  1724.                                 treeView.Nodes.Add(root);
  1725.                             }
  1726.                             //Initalize the nodes 
  1727.                             root = new TreeNode();
  1728.                             child1 = new TreeNode();
  1729.                             child2 = new TreeNode();
  1730.                             child3 = new TreeNode();
  1731.                             child4 = new TreeNode();
  1732.                             child5 = new TreeNode();
  1733.                             child6 = new TreeNode();
  1734.                             child7 = new TreeNode();
  1735.                             child8 = new TreeNode();
  1736.                             child9 = new TreeNode();
  1737.                             child10 = new TreeNode();
  1738.                             child11 = new TreeNode();
  1739.                             child12 = new TreeNode();
  1740.                             //Fill the intialized nodes with the info in the current item.  Since this is a non-matching
  1741.                             //item then we also initialize the main root node.
  1742.                             root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
  1743.                                 child6, child7, child8, child9, child10, child11, child12, true);
  1744.                         }
  1745.                     }
  1746.                     else
  1747.                     {
  1748.                         //Since we are soting by date and the dates of the current and previous item do not match we
  1749.                         //need to make a break and create a new node to hold the info
  1750.                         //
  1751.                         //Add the node to the grouping node
  1752.                         alternateRoot.ChildNodes.Add(root);
  1753.                         //Add the grouping node to the TreeView
  1754.                         treeView.Nodes.Add(alternateRoot);
  1755.                         //Initialize a new grouping node
  1756.                         alternateRoot = new TreeNode();
  1757.                         //Set the grouping node text to do nothing when clicked on
  1758.                         alternateRoot.SelectAction = TreeNodeSelectAction.None;
  1759.                         if (sortBy == "mr_date" || sortBy == "date")
  1760.                         {
  1761.                             if (treeItem1.rawAirDateStartTime != null)
  1762.                             {
  1763.                                 if (sortBy == "mr_date")
  1764.                                 {
  1765.                                     alternateRoot.Text = treeItem1.rawAirDateStartTime.ToLongDateString();
  1766.                                 }
  1767.                                 else
  1768.                                 {
  1769.                                     alternateRoot.Text = treeItem1.airDate;
  1770.                                 }
  1771.                             }
  1772.                             else
  1773.                             {
  1774.                                 alternateRoot.Text = "No Air Date Found:";
  1775.                             }
  1776.                         }
  1777.                         else if (sortBy == "originalAirDate" || sortBy == "mr_original_date")
  1778.                         {
  1779.                             if (guideParams.showAirDate)
  1780.                             {
  1781.                                 if (treeItem1.rawOriginalAirDate != null)
  1782.                                 {
  1783.                                     alternateRoot.Text = treeItem1.originalAirDate;
  1784.                                 }
  1785.                                 else
  1786.                                 {
  1787.                                     alternateRoot.Text = "No Original Air Date Found:";
  1788.                                 }
  1789.                             }
  1790.                             else
  1791.                             {
  1792.                                 alternateRoot.Text = "Original Air Date not selected to display in Configuration Tab:";
  1793.                             }
  1794.                         }
  1795.                         else if (sortBy == "mr_channel")
  1796.                         {
  1797.                             alternateRoot.Text = treeItem1.channelName;
  1798.                         }
  1799.                         else
  1800.                         {
  1801.                             alternateRoot.Text = treeItem1.status;
  1802.                         }
  1803.                         //Initalize the nodes 
  1804.                         root = new TreeNode();
  1805.                         child1 = new TreeNode();
  1806.                         child2 = new TreeNode();
  1807.                         child3 = new TreeNode();
  1808.                         child4 = new TreeNode();
  1809.                         child5 = new TreeNode();
  1810.                         child6 = new TreeNode();
  1811.                         child7 = new TreeNode();
  1812.                         child8 = new TreeNode();
  1813.                         child9 = new TreeNode();
  1814.                         child10 = new TreeNode();
  1815.                         child11 = new TreeNode();
  1816.                         child12 = new TreeNode();
  1817.                         //Fill the intialized nodes with the info in the current item.  Since this is a non-matching
  1818.                         //item then we also initialize the main root node.
  1819.                         root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
  1820.                             child6, child7, child8, child9, child10, child11, child12, true);
  1821.                     }
  1822.                 }
  1823.                 //Up the index of the loop
  1824.                 idx1++;
  1825.             }
  1826.  
  1827.             //If you are not sorting by title then load the last node filed to the grouping node and then
  1828.             //the grouping node to the TreeView otherwise just load the node to the Treeview
  1829.             if (sortBy != "title" && sortBy != "mr_title")
  1830.             {
  1831.                 alternateRoot.ChildNodes.Add(root);
  1832.                 treeView.Nodes.Add(alternateRoot);
  1833.             }
  1834.             else
  1835.             {
  1836.                 treeView.Nodes.Add(root);
  1837.             }
  1838.         }
  1839.  
  1840.         private TreeNode FillProgrammeTree(ProgramTreeItem treeItem1, Settings guideParams, TreeNode root, TreeNode child1,
  1841.                                                 TreeNode child2, TreeNode child3, TreeNode child4, TreeNode child5,
  1842.                                                 TreeNode child6, TreeNode child7, TreeNode child8, TreeNode child9,
  1843.                                                 TreeNode child10, TreeNode child11, TreeNode child12, bool fillRoot)
  1844.         {
  1845.             //**************
  1846.             //This method loads the nodes that will ultimatley be loaded into a TreeView control for displaying program
  1847.             //information.
  1848.             //**************
  1849.             //
  1850.             if (fillRoot)
  1851.             {
  1852.                 FillProgrammeTreeTitle(treeItem1, root);
  1853.             }
  1854.             FillProgrammeTreeSubTitle(treeItem1, child1);
  1855.             root.ChildNodes.Add(child1);
  1856.  
  1857.             if (guideParams.showDescription)
  1858.             {
  1859.                 FillProgrammeTreeDescription(treeItem1, child2, child3);
  1860.                 
  1861.                 //If the description is empty do not display it.
  1862.                 if (child3.Text.Length > 0)
  1863.                 {
  1864.                     child1.ChildNodes.Add(child2);
  1865.                     child3.SelectAction = TreeNodeSelectAction.None;
  1866.                     child2.ChildNodes.Add(child3);
  1867.                 }
  1868.             }
  1869.  
  1870.             FillProgrammeTreeCommon(treeItem1, child4, child5, child6, child7, child8, child9, child10);
  1871.             if (guideParams.showRating)
  1872.             {
  1873.                 // Create Child Node for rating
  1874.                 if (child4.Text != String.Empty)
  1875.                 {
  1876.                     child4.SelectAction = TreeNodeSelectAction.None;
  1877.                     child1.ChildNodes.Add(child4);
  1878.                 }
  1879.             }
  1880.  
  1881.             if (guideParams.showGenre != "noGenre")
  1882.             {
  1883.                 // Create Child Node for Genre
  1884.                 if (child5.Text != String.Empty)
  1885.                 {
  1886.                     child5.SelectAction = TreeNodeSelectAction.None;
  1887.                     child1.ChildNodes.Add(child5);
  1888.                 }
  1889.             }
  1890.  
  1891.             if (guideParams.showAirDate)
  1892.             {
  1893.                 // Create Child Node for Release Year
  1894.                 if (child6.Text != String.Empty)
  1895.                 {
  1896.                     child6.SelectAction = TreeNodeSelectAction.None;
  1897.                     child1.ChildNodes.Add(child6);
  1898.                 }
  1899.             }
  1900.  
  1901.             if (guideParams.showStarRating)
  1902.             {
  1903.                 // Create Child Node for Star Rating
  1904.                 if (child7.Text != String.Empty)
  1905.                 {
  1906.                     child7.SelectAction = TreeNodeSelectAction.None;
  1907.                     child1.ChildNodes.Add(child7);
  1908.                 }
  1909.             }
  1910.  
  1911.             if (guideParams.showAirDate)
  1912.             {
  1913.                 // Create Child Node for Original Air Date
  1914.                 if (child8.Text != String.Empty)
  1915.                 {
  1916.                     child8.SelectAction = TreeNodeSelectAction.None;
  1917.                     child1.ChildNodes.Add(child8);
  1918.                 }
  1919.             }
  1920.  
  1921.             if (guideParams.showNew)
  1922.             {
  1923.                 // Create Child Node for a new show
  1924.                 if (child9.Text != String.Empty)
  1925.                 {
  1926.                     child9.SelectAction = TreeNodeSelectAction.None;
  1927.                     child1.ChildNodes.Add(child9);
  1928.                 }
  1929.             }
  1930.  
  1931.             if (guideParams.showCredits)
  1932.             {
  1933.                 // Create Child Node for Credits
  1934.                 if (child10.Text != String.Empty)
  1935.                 {
  1936.                     child10.SelectAction = TreeNodeSelectAction.None;
  1937.                     child1.ChildNodes.Add(child10);
  1938.                 }
  1939.             }
  1940.  
  1941.             //Set the 12th level of the tree for the show to the Date and time the show is available
  1942.             FillProgrammeTreeAirDate(treeItem1, child11);
  1943.             child11.SelectAction = TreeNodeSelectAction.None;
  1944.             child11.Expand();
  1945.             child1.ChildNodes.Add(child11);
  1946.  
  1947.             //Set the 13th level of the tree for the show to the Channel which has a check box for multi-recording selection option
  1948.             FillProgrammeTreeChannel(treeItem1, child12);
  1949.             child12.SelectAction = TreeNodeSelectAction.None;
  1950.             if (treeItem1.displayClass == "listing")
  1951.             {
  1952.                 child12.ShowCheckBox = true;
  1953.             }
  1954.             child11.ChildNodes.Add(child12);
  1955.  
  1956.             return (root);
  1957.  
  1958.         }
  1959.  
  1960.         #region Methods that load TreeNodes with info from a ProgrammeTreeItem Object
  1961.  
  1962.         private void FillProgrammeTreeTitle(ProgramTreeItem treeItem, TreeNode treeNode)
  1963.         {
  1964.             treeNode.Text = treeItem.title;
  1965.             treeNode.SelectAction = TreeNodeSelectAction.None;
  1966.             treeNode.Expand();
  1967.         }
  1968.  
  1969.         private void FillProgrammeTreeSubTitle(ProgramTreeItem treeItem, TreeNode treeNode)
  1970.         {
  1971.             treeNode.Text = treeItem.subtitle;
  1972.             if (treeItem.displayClass != "listing")
  1973.             {
  1974.                 treeNode.Text = treeNode.Text.Replace("class=\"listing\"", "class=\"" + treeItem.displayClass + "\"");
  1975.                 treeNode.Text = treeNode.Text.Replace("class=\"showSubtitle\"", "class=\"" + treeItem.displayClass + "\"");
  1976.             }
  1977.             treeNode.SelectAction = TreeNodeSelectAction.None;
  1978.             if (SortBy != null && SortBy.Length > 2)
  1979.             {
  1980.                 if (treeItem.status == "Reocurring")
  1981.                 {
  1982.                     treeNode.Text = "Season Recording" + treeNode.Text;
  1983.                 }
  1984.                 else
  1985.                 {
  1986.                     if (treeItem.rawOriginalAirDate != null)
  1987.                     {
  1988.                         treeNode.Text = "(ad: " + treeItem.rawAirDateStartTime.ToShortDateString() + ") " + treeNode.Text + "  (oad: " + treeItem.rawOriginalAirDate + ")";
  1989.                     }
  1990.                     else
  1991.                     {
  1992.                         treeNode.Text = "(ad: " + treeItem.rawAirDateStartTime.ToShortDateString() + ") " + treeNode.Text;
  1993.                     }                        
  1994.                 }
  1995.             }
  1996.         }
  1997.  
  1998.         private void FillProgrammeTreeDescription(ProgramTreeItem treeItem, TreeNode treeNode1, TreeNode treeNode2)
  1999.         {
  2000.             treeNode1.Text = "<span>Description: </span>";
  2001.             treeNode1.SelectAction = TreeNodeSelectAction.None;
  2002.             treeNode1.Expand();
  2003.  
  2004.             treeNode2.Text = treeItem.description;
  2005.         }
  2006.  
  2007.         private void FillProgrammeTreeCommon(ProgramTreeItem treeItem, TreeNode treeNode1, TreeNode treeNode2, TreeNode treeNode3, TreeNode treeNode4, TreeNode treeNode5, TreeNode treeNode6, TreeNode treeNode7)
  2008.         {
  2009.             treeNode1.Text = treeItem.rating;
  2010.  
  2011.             treeNode2.Text = treeItem.genre;
  2012.  
  2013.             treeNode3.Text = treeItem.releaseYear;
  2014.  
  2015.             treeNode4.Text = treeItem.starRating;
  2016.  
  2017.             treeNode5.Text = treeItem.originalAirDate;
  2018.  
  2019.             treeNode6.Text = treeItem.new_show;
  2020.  
  2021.             treeNode7.Text = treeItem.credits;
  2022.  
  2023.         }
  2024.  
  2025.         private void FillProgrammeTreeAirDate(ProgramTreeItem treeItem, TreeNode treeNode)
  2026.         {
  2027.             treeNode.Text = treeItem.getAirDate();
  2028.             if (treeItem.getRecordingDisplayClass() != "listing")
  2029.             {
  2030.                 treeNode.Text = treeNode.Text.Replace("class=\"listing\"", "class=\"" + treeItem.displayClass + "\"");
  2031.             }
  2032.         }
  2033.  
  2034.         private void FillProgrammeTreeChannel(ProgramTreeItem treeItem, TreeNode treeNode)
  2035.         {
  2036.             treeNode.Text = treeItem.channelDisplay;
  2037.             treeNode.Value = treeItem.programmeOID;
  2038.             treeNode.Text += treeItem.buttonOptions;
  2039.         }
  2040.         #endregion
  2041.     }
  2042. }
  2043.